﻿using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace EFCoreLock.Migrations
{
    /// <inheritdoc />
    public partial class init : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "T_Employee",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Age = table.Column<int>(type: "int", nullable: false),
                    Address = table.Column<string>(type: "nvarchar(max)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_Employee", x => x.Id);
                },
                comment: "员工信息表");

            migrationBuilder.CreateTable(
                name: "T_Work",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Content = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true, comment: "工作内容"),
                    WorkArea = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    EmployeeId = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_Work", x => x.Id);
                    table.ForeignKey(
                        name: "FK_T_Work_T_Employee_EmployeeId",
                        column: x => x.EmployeeId,
                        principalTable: "T_Employee",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "工作表");

            migrationBuilder.CreateIndex(
                name: "IX_T_Work_EmployeeId",
                table: "T_Work",
                column: "EmployeeId",
                unique: true);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "T_Work");

            migrationBuilder.DropTable(
                name: "T_Employee");
        }
    }
}
